package br.com.mmm.javacenter.framework.view.formatters;

import br.com.mmm.javacenter.framework.annotations.FormatterComponent;
import br.com.mmm.javacenter.framework.configuration.IocController;

public final class FormatterFactory {
	public static Formatter getFormatter(Class<?> klass){
		for(Class<?> k:IocController.formattersBeans){
			Class<?>[] antende = ((FormatterComponent) k.getAnnotation(FormatterComponent.class)).value();
			for(Class<?> k2:antende){
				if(k2 == klass || k2.isAssignableFrom(klass)){
					return (Formatter) IocController.picoSetterContainer.getComponentInstanceOfType(k);
				}
			}
		}
		return null;
	}
}
